package com.example.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.domain.entity.OrderItem;
import com.example.exception.FloraException;
import com.example.service.OrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@ResponseBody
@RequestMapping("/orderItem")
public class OrderItemController {
    @Autowired
    private OrderItemService orderItemService;

    @GetMapping("/orderItem")
    public IPage<OrderItem> getOrderItem(Long orderId, Integer pageNum, Integer pageSize) throws FloraException {
        return orderItemService.getOrderItem(orderId,pageNum,pageSize);
    }
    @PostMapping("/add")
    public OrderItem addOrderItem(@RequestBody OrderItem orderItem) throws FloraException {
        return orderItemService.addOrderItem(orderItem);
    }

    @DeleteMapping("/{id}")
    public void deleteOrder(Long orderId) throws FloraException {
        orderItemService.deleteOrderItem(orderId);
    }

}
